/**
 * Rectangle is used to build rectangles using the cartesian coordinate sys.
 * 
 * @author Dr. Joshua Delinjer
 * @edited by Mohammed Alghareeb
 *
 */
public class Rectangle {
	private Point firstCoordinate, secondCoordinate;
	
	Rectangle(Point firstPoint, Point secondPoint) {
		this.firstCoordinate = firstPoint;
		this.secondCoordinate = secondPoint;
	}
	/**
	 * getArea is a method that calculate the rectangle area.
	 * 
	 * @return the absolute  value of rectangle area.
	 * 
	 */
	public Double getArea() {
		
		double rectLength = secondCoordinate.xCoordinate - firstCoordinate.xCoordinate;
		double rectWidth = secondCoordinate.yCoordinate - firstCoordinate.yCoordinate;
		double rectArea = rectLength * rectWidth;
		return Math.abs(rectArea);
	}
	/**
	 * getDiagonal is a method that calculate the rectangle diagonal
	 *  
	 * @return the square root of (x2-x1)^2 + (y2 - y1)^2
	 */
	public Double getDiagonal() {
		
		double rectLength = secondCoordinate.xCoordinate - firstCoordinate.xCoordinate;
		double rectWidth = secondCoordinate.yCoordinate - firstCoordinate.yCoordinate;
		double pointOne = Math.pow(rectLength, 2);
		double pointTwo = Math.pow(rectWidth, 2);
		double diagnolDistance = pointOne + pointTwo;
		return Math.sqrt(diagnolDistance);
	}
}
